/*
  ID: nemokin1
  PROG: sprime
  LANG: C++
  using: truncate dfs, seems use too much time
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

bool prime(int n)
{
    if(n<=1) return false;
    else if(n<4) return true;
    else if(n%2==0) return false;
    else if(n<9) return true;
    else if(n%3==0) return false;
    else{
        int f=5;
	int r = (int)sqrt(n)+1;
	while(f<=r){
            if(n%f==0) return false;
            if(n%(f+2)==0) return false;
            f+=6;
	}
        return true;
    }
}

int len(int n)
{
    int cnt = 0;
    
    while(n) {
	cnt++;
	n/=10;
    }
    return cnt;
}

int main() {
    freopen("sprime.in","r",stdin);freopen("sprime.out","w",stdout);
    int N;
    cin >> N;
    
    queue<int> q;
    vector<int> ret;
    for(int i = 2; i < 10; i++)
	if(prime(i)) q.push(i);
    while(!q.empty()){
	int p = q.front();
	q.pop();
	if(len(p) == N) ret.push_back(p);
	if(len(p) == N+1) break;
	for(int i = 1; i < 10; i++){
	    if(prime(p*10+i))
		q.push(p*10+i);
	}
    }
    for(int i = 0; i < ret.size(); i++)
	cout << ret[i] << endl;
    
    exit(0);
}
    
